import { createElement, serializeLabel } from '../utils'

/**
 * 套娃的圆半径
 */
// export default (expression: any, { metadata }: any) => {
//   const { stops } = expression
//   return createElement('ul', {
//     classes: 'bubbles',
//     content: stops.sort((a: any, b: any) => b[1] - a[1]) // order from bigger to smaller
//       .map(([value, radius]: any) => createElement('li', {
//         styles: { '--radius': `${radius}px` },
//         content: createElement('span', {
//           content: serializeLabel(value, metadata),
//         })
//       }))
//   })
// }

/**
 * 列表圆半径
 * @param expression
 * @param metadata
 */
export default (expression: any, { metadata }: any) => {
  const { stops } = expression
  return createElement('ul', {
    classes: ['list', 'list--bubbles'],
    content: stops
      .sort((a: any, b: any) => a[1] - b[1]) // order from bigger to smaller
      .map(([value, radius]: any) =>
        createElement('li', {
          styles: { '--radius': `${radius}px` },
          content: serializeLabel(value, metadata),
        })
      ),
  })
}
